package com.ciko.code.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ciko.code.base.adapter.CommonAdapter;
import com.ciko.code.base.adapter.ViewHolder;
import com.ciko.code.bean.SelAcceptPlanEty;
import com.ciko.code.utils.DateUtil;
import com.mywork.R;

import java.util.List;


/**
 * Created by ciko on 2015/12/7.
 */
public class WorkPlaneListAdapter
		extends
		CommonAdapter<SelAcceptPlanEty>
{
	private int TYPE = 0;

	public WorkPlaneListAdapter(Context context, List<SelAcceptPlanEty> mDatas, int itemLayoutId) {
		super(context, mDatas, itemLayoutId);
	}

	public WorkPlaneListAdapter(int TYPE, Context context, List<SelAcceptPlanEty> mDatas, int itemLayoutId) {
		super(context, mDatas, itemLayoutId);
		this.TYPE = TYPE;
	}

	@Override
	public void convert(ViewHolder helper, SelAcceptPlanEty item) {
		if (item.getPlanType().equals("周报"))
		{
			helper.setText(R.id.tv_planType, "周报");
			helper.setText(R.id.tv_work_status,"本周工作情况");
			helper.setText(R.id.tv_work_plan,"下周工作计划");
		}
		else if (item.getPlanType().equals("月报"))
		{
			helper.setText(R.id.tv_planType, "月报");
			helper.setText(R.id.tv_work_status,"本月工作情况");
			helper.setText(R.id.tv_work_plan,"下月工作计划");
		}
		else if (item.getPlanType().equals("季报"))
		{
			helper.setText(R.id.tv_planType, "季报");
			helper.setText(R.id.tv_work_status,"本季工作情况");
			helper.setText(R.id.tv_work_plan,"下季工作计划");
		}
		helper.setText(R.id.tv_completeWork, item.getCompleteWork());
		//        helper.setText(R.id.tv_workSummary, item.getWorkSummary());
		helper.setText(R.id.tv_workPlan, item.getWorkPlan());
		helper.setText(R.id.tv_help, item.getHelp());
		helper.setText(R.id.tv_remarks, item.getRemarks());
		helper.setText(R.id.tv_person, TYPE == 1 ? "发送人员:" : "接收人员:");
		helper.getView(R.id.ll_person).setVisibility(TYPE == 1 ? View.GONE : View.VISIBLE);
		helper.setText(R.id.tv_acceptName, TYPE == 1 ? item.getCreateName() : item.getAcceptName());
		helper.setText(R.id.tv_time, DateUtil.longToDate(item.getCreateTime(), 8));
		helper.setText(R.id.tv_head_img_name, item.getCreateName());
		helper.setText(R.id.tv_receive_time, TYPE == 1 ? "接收时间" : "发出时间");
		helper.getView(R.id.ll_remarks).setVisibility(item.getRemarks() == null || item.getRemarks().equals("") ? View.GONE : View.VISIBLE);
		helper.getView(R.id.ll_help).setVisibility(item.getHelp() == null || item.getHelp().equals("") ? View.GONE : View.VISIBLE);
		helper.getView(R.id.ll_fujian).setVisibility(item.getEnclosure().equals("") ? View.GONE : View.VISIBLE );

		switch (item.getStatus()) {
			case "1":
				helper.setText(R.id.tv_status, "还未接收");
				((TextView) helper.getView(R.id.tv_status)).setTextColor(mContext.getResources().getColor(R.color.red_dot));
				break;
			case "2":
				helper.setText(R.id.tv_status, "已拒绝");
				((TextView) helper.getView(R.id.tv_status)).setTextColor(mContext.getResources().getColor(R.color.common_red));
				break;
			case "3":
				helper.setText(R.id.tv_status, "接收");
				((TextView) helper.getView(R.id.tv_status)).setTextColor(mContext.getResources().getColor(R.color.booknote_txt_blue));
				break;
			case "4":
				helper.setText(R.id.tv_status, "已完成");
				((TextView) helper.getView(R.id.tv_status)).setTextColor(mContext.getResources().getColor(R.color.booknote_txt_blue));
				break;

		}
	}
}
